package com.chang.dp.controller;

import com.chang.dp.common.Result;
import com.chang.dp.entity.BookSectionEntity;
import com.chang.dp.services.impl.BookSectionServiceImpl;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/bookSection")
public class BookSectionController {
    @Resource
    private BookSectionServiceImpl bookSectionServiceImpl;
    @RequestMapping("/detail/{id}")
    public Result<BookSectionEntity> detail(@PathVariable("id") Long id) {
        BookSectionEntity bookSection = bookSectionServiceImpl.getById(id);
        return Result.success(bookSection);
    }
    @GetMapping("/listByBookId/{bookId}")
    public Result<List<BookSectionEntity>> listByBookId(@PathVariable("bookId") Long bookId) {
        List<BookSectionEntity> list = bookSectionServiceImpl.listByBookId(bookId);

        return Result.success(list);
    }
}
